using System;
using SpecificationPatternCodeV2.Abstracts;

namespace SpecificationPatternCodeV2.Base
{
	public class LessThanOrEqualToSpecification<T> : CompositeSpecification<T> where T : IComparable<T>
	{
		private readonly T _upper;

		public LessThanOrEqualToSpecification(T upper)
		{
			_upper = upper;
		}

		public override bool IsSatisfiedBy(T candidate)
		{
			return candidate.CompareTo(_upper) <= 0;
		}
	}
}